package com.Exception;

import java.util.Scanner;

public class Demo03 {
    public static void main(String[] args) {
        Student s = new Student();
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入你的姓名");
        String name = sc.nextLine();
        s.setName(name);
        while (true) {
            System.out.println("请输入你的年龄");
            String ageStr = sc.nextLine();
            try {
                int age=Integer.parseInt(ageStr);
                s.setAge(age);
                break;
            } catch (NumberFormatException e) {
                System.out.println("请输入一个整数");
                continue;
            }catch (AgeOutOfExceeption e) {
                System.out.println("你输入的年龄超出范围");
                continue;
            }
        }
        System.out.println(s);
    }
}
